<div class="container" ng-if="state =='loading'">
    <div class="page-header">
        <h1>数据加载中......ヾ(ｏ･ω･)ﾉ</h1>
    </div>
</div>
<div class="container" ng-if="state == 'error'">
    <div class="page-header">
        <h1>加载失败啦ミﾟДﾟ彡,刷新下页面试试</h1>
    </div>
</div>
<div class="container" ng-if="state == 'finished'">
    <div class="page-header">
        <h1>导师管理</h1>
    </div>
    <div class="row">
        <table class="table table-striped">
            <thead>
                <tr>
                    <td>姓名</td>
                    <td>职称</td>
                    <td>电话</td>
                    <td>邮箱</td>
                    <td><a href="" class="text-success" ng-click="addTeacher()"><span class="glyphicon glyphicon-plus"></span></a></td>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="teacher in allTeachers ">
                    <td>{{teacher.tutorName}}</td>
                    <td>{{teacher.tutorTitle}}</td>
                    <td>{{teacher.phoneNumber}}</td>
                    <td>{{teacher.email}}</td>
                    <td>
                        <!--修改-->
                        <a href="" class="text-primary" ng-click="updateTeacher(teacher)"><span class="glyphicon glyphicon-pencil"></span></a>
                        <!--删除-->
                        <a href="" class="text-danger" ng-click="deleteTeacher(teacher)"><span class="glyphicon glyphicon-remove"></span></a>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<script type="text/ng-template" id="add-teacher-dialog.html">
    <div class="modal-header">
        <h3 class="modal-title">添加导师</h3>
    </div>
    <div class="modal-body">
            <form name="addTeacherForm">
                <div class="form-group has-feedback" ng-class="{
                'has-success':addTeacherForm.tutorName.$valid,
                'has-error':addTeacherForm.tutorName.$invalid}">
                    <label>姓名</label>
                    <input name="tutorName" type="text" ng-model="newTeacher.tutorName" class="form-control" required>
                    <span class="help-block" ng-show="addTeacherForm.tutorName.$invalid">请填写姓名</span>
                </div>
                <div class="form-group has-feedback" ng-class="{
                'has-success':addTeacherForm.tutorTitle.$valid,
                'has-error':addTeacherForm.tutorTitle.$invalid}">
                    <label>职称</label>
                    <select class="form-control" name="tutorTitle" ng-options="option for option in tutorTitles" ng-model="newTeacher.tutorTitle" required></select>
                    <span class="help-block" ng-show="addTeacherForm.tutorTitle.$invalid">请选择职称</span>
                </div>
                <div class="form-group has-feedback" ng-class="{
                'has-success':addTeacherForm.phoneNumber.$valid,
                'has-error':addTeacherForm.phoneNumber.$invalid}">
                    <label>电话</label>
                    <input name="phoneNumber" type="text" ng-pattern="/^1\d{10}$/" ng-model="newTeacher.phoneNumber" class="form-control" required>
                    <span class="help-block" ng-show="addTeacherForm.phoneNumber.$error.required">请填写电话号码</span>
                    <span class="help-block" ng-show="addTeacherForm.phoneNumber.$error.pattern">电话号码格式不正确</span>
                </div>
                <div class="form-group has-feedback" ng-class="{
                'has-success':addTeacherForm.email.$valid,
                'has-error':addTeacherForm.email.$invalid}">
                    <label>邮箱</label>
                    <input name="email" type="email" ng-model="newTeacher.email" class="form-control" required>
                    <span class="help-block" ng-show="addTeacherForm.email.$error.required">请填写邮箱</span>
                    <span class="help-block" ng-show="addTeacherForm.email.$error.email">邮箱格式不正确</span>
                </div>
            </form>
    </div>
    <div class="modal-footer">
        <button class="btn btn-success" type="button" ng-show="isDone" ng-class="{disabled:addTeacherForm.$invalid}" ng-click="addTeacherForm.$valid && submit()">确认</button>
        <button class="btn btn-warning disabled" type="button" ng-show="!isDone">添加中...</button>
        <button class="btn btn-danger" type="button" ng-click="dismiss()">取消</button>
    </div>
</script>
<script type="text/ng-template" id="update-teacher-dialog.html">
    <div class="modal-header">
        <h3 class="modal-title">修改导师</h3>
    </div>
    <div class="modal-body">
        <form name="addTeacherForm">
            <div class="form-group has-feedback" ng-class="{
                'has-success':addTeacherForm.tutorName.$valid,
                'has-error':addTeacherForm.tutorName.$invalid}">
                <label>姓名</label>
                <input name="tutorName" type="text" ng-model="tempTeacher.tutorName" class="form-control" required>
                <span class="help-block" ng-show="addTeacherForm.tutorName.$invalid">请填写姓名</span>
            </div>
            <div class="form-group has-feedback" ng-class="{
                'has-success':addTeacherForm.tutorTitle.$valid,
                'has-error':addTeacherForm.tutorTitle.$invalid}">
                <label>职称</label>
                <select class="form-control" name="tutorTitle" ng-options="option for option in tutorTitles" ng-model="tempTeacher.tutorTitle" required></select>
                <span class="help-block" ng-show="addTeacherForm.tutorTitle.$invalid">请选择职称</span>
            </div>
            <div class="form-group has-feedback" ng-class="{
                'has-success':addTeacherForm.phoneNumber.$valid,
                'has-error':addTeacherForm.phoneNumber.$invalid}">
                <label>电话</label>
                <input name="phoneNumber" type="text" ng-pattern="/^1\d{10}$/" ng-model="tempTeacher.phoneNumber" class="form-control" required>
                <span class="help-block" ng-show="addTeacherForm.phoneNumber.$error.required">请填写电话号码</span>
                <span class="help-block" ng-show="addTeacherForm.phoneNumber.$error.pattern">电话号码格式不正确</span>
            </div>
            <div class="form-group has-feedback" ng-class="{
                'has-success':addTeacherForm.email.$valid,
                'has-error':addTeacherForm.email.$invalid}">
                <label>邮箱</label>
                <input name="email" type="email" ng-model="tempTeacher.email" class="form-control" required>
                <span class="help-block" ng-show="addTeacherForm.email.$error.required">请填写邮箱</span>
                <span class="help-block" ng-show="addTeacherForm.email.$error.email">邮箱格式不正确</span>
            </div>
        </form>
    </div>
    <div class="modal-footer">
        <button class="btn btn-success" type="button" ng-show="isDone"
                ng-class="{disabled:addTeacherForm.$invalid}" ng-click="addTeacherForm.$valid && submit()">确认</button>
        <button class="btn btn-warning disabled" type="button" ng-show="!isDone">修改中...</button>
        <button class="btn btn-danger" type="button" ng-click="dismiss()">取消</button>
    </div>
</script>
<script type="text/ng-template" id="delete-teacher-dialog.html">
    <div class="modal-header">
        <h3>删除导师</h3>
    </div>
    <div class="modal-body">
        <p>您确定要删除该导师吗?</p>
    </div>
    <div class="modal-footer">
        <button class="btn btn-success" type="button" ng-show="isDone" ng-click="submit()">确认</button>
        <button class="btn btn-warning disabled" type="button" ng-show="!isDone">删除中...</button>
        <button class="btn btn-danger" type="button" ng-click="dismiss()">取消</button>
    </div>
</script>